<html lang="en">
<head>
    <title>注册游记管理</title>
<#include  "../common/header.ftl">
    <script type="text/javascript" src="/js/My97DatePicker/WdatePicker.js"></script>

    <style>
        #travelModal img {
            width: 100%;
        }

        #travelModal .modal-body {
            max-height: 600px;
            overflow-y: auto;
        }
    </style>

    <script>
        $(function () {
            $(".update").click(function () {
                $("#editForm")[0].reset();
                var json = $(this).data("json");
                console.log(json);
                if (json) {
                    $("#travelCommendModal input[name='title']").val(json.title)
                    $("#travelCommendModal input[name='id']").val(json.id)
                    $("#travelCommendModal input[name='subTitle']").val(json.subTitle)
                    $("#travelCommendModal img").attr("src", json.coverUrl);
                    $("#travelCommendModal input[name='coverUrl']").val(json.coverUrl);
                    $("#travelCommendModal input[name='schedule']").val(json.schedule)
                    $("#travelCommendModal input[name='travelId']").val(json.travelId)
                    $("#travelCommendModal select[name='type']").val(json.type)
                    $("#skip").attr("data-tid", json.travelId);
                }

                $("#travelCommendModal").modal("show");
            })

            $("#saveBtn").click(function () {
                $("#editForm").submit();
            })

            $("#skip").click(function () {
                var tid = $(this).data("tid")
                window.open("/travel/releaseList.do?travelId=" + tid);
            })
        })
    </script>
</head>
<body>
<!--左侧菜单回显变量设置-->
<#assign currentMenu='travelCommend'>


<div class="container " style="margin-top: 20px">
<#include  "../common/top.ftl">
    <div class="row">
        <div class="col-sm-2">
        <#include  "../common/menu.ftl">
        </div>
        <div class="col-sm-10">
            <div class="row">
                <div class="col-sm-12">
                    <h1 class="page-head-line">待审核游记管理</h1>
                </div>
            </div>
            <!--高级查询--->
            <form class="form-inline" id="searchForm" action="/travelCommend/list.do" method="post">
                <input type="hidden" name="currentPage" id="currentPage" value="1">
                <div class="form-group">
                    <label for="keyword">关键字:</label>
                    <input type="text" class="form-control" id="keyword" name="keyword" value="${qo.keyword!}"
                           placeholder="请输入昵称/邮箱">
                </div>
                <div class="form-group">
                    <div class="col-sm-6">
                        <select id="type" class="form-control" autocomplete="off" name="type">
                            <option value="-1">全部</option>
                            <option value="1">每月推荐</option>
                            <option value="0">每周推荐</option>
                            <option value="2">攻略推荐</option>
                        </select>
                    </div>
                </div>
                <script>
                    $("#type option[value='${qo.type}']").attr("selected", true);
                </script>
                <button id="btn_query" class="btn btn-info"><span class="glyphicon glyphicon-search"></span> 查询</button>
                <a href="javascript:void(-1);" class="btn btn-success update" id="addTravelCommendBtn">添加推荐游记</a>
            </form>

            <table class="table table-striped table-hover">
                <thead>
                <th>编号</th>
                <th>封面</th>
                <th>标题</th>
                <th>副标题</th>
                <th>推荐时间</th>
                <th>推荐类型</th>
                <th>操作</th>
                </tr>
                </thead>
            <#list result.list as entity>
                <tr>
                    <td>${entity_index + 1}</td>
                    <td>${(entity.title)!}</td>
                    <td>${(entity.subTitle)!}</td>
                    <td><img src="${entity.coverUrl!}" width="40px"></td>
                    <td>${(entity.schedule?string('yyyy-MM-dd'))!}</td>
                    <td>${(entity.typeDisplay)!}</td>
                    <td>
                        <a href="javascript:;" data-json='${entity.jsonString}' data-tid="${entity.id}" class="update">修改</a>&nbsp;&nbsp;
                    </td>
                </tr>
            </#list>

            </table>
        <#include "../common/page.ftl">
        </div>
    </div>
</div>


<#--模态框-->
<div id="travelCommendModal" class="modal" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title">编辑/增加</h4>
            </div>
            <div class="modal-body">
                <form id="editForm" class="form-horizontal" method="post" action="/travelCommend/saveOrUpdate.do"
                      enctype="multipart/form-data" style="margin: -3px 118px">
                    <input id="travelCommendId" type="hidden" name="id"/>
                    <input id="travelId" type="hidden" name="travelId"/>
                    <div class="form-group">
                        <label class="col-sm-4 control-label">标题</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="title" name="title" placeholder="标题">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label">副标题</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="subTitle" name="subTitle" placeholder="副标题">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label">封面</label>
                        <div class="col-sm-6">
                            <img id="coverUrl" width="200px"/>
                            <input type="file" class="form-control" id="pic" name="file">
                            <input type="hidden" name="coverUrl">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label">推荐时间</label>
                        <div class="col-sm-6">
                            <input type="text" id="schedule" name="schedule" class="form-control"
                                   onclick="WdatePicker()">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label">推荐类型</label>
                        <div class="col-sm-6">
                            <select id="type" class="form-control" autocomplete="off" name="type">
                                <option value="1">月推荐</option>
                                <option value="0">周推荐</option>
                                <option value="2">攻略推荐</option>
                            </select>
                        </div>
                        <script>
                            $("#type option[value='${qo.type}']").attr("selected", true);
                        </script>
                    </div>
                    <div class="form-group" style="text-align: center">
                        <a href="javascript:void(0)" target="_blank" id="skip">点击查看游记文章明细</a>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <a href="javascript:void(0);" class="btn btn-success" id="saveBtn" aria-hidden="true">保存</a>
                <a href="javascript:void(0);" class="btn" data-dismiss="modal" aria-hidden="true">关闭</a>
            </div>
        </div>
    </div>
</div>

</body>
</html>